<?php
require 'db.php';
$manhom="";
$manhom=isset($_REQUEST['manhom'])?$_REQUEST['manhom']:'';
if(isset($_POST['btnsua'])){
	$manhom=isset($_REQUEST['manhom'])?$_REQUEST['manhom']:'';
	$masv=isset($_REQUEST['mssv'])?$_REQUEST['mssv']:'';
	$diem=isset($_REQUEST['thanhtich'])?$_REQUEST['thanhtich']:'';
	$nhanxet=isset($_REQUEST['nhanxet'])?$_REQUEST['nhanxet']:'';
	$thuong=isset($_REQUEST['thuong'])?$_REQUEST['thuong']:'';
		$sqldiem = 'update dbo_dondangky set thanhtich=? where masv=? and manhom=?';
	$stmt1 = $db->prepare ($sqldiem );
	$stmt1->BindParam(1,$diem);
	$stmt1->BindParam(2,$masv);
	$stmt1->BindParam(3,$manhom);
	$stmt1->execute();
		exit();
}
if(isset($_POST['btnsuanx'])){
	$manhom=isset($_REQUEST['manhom'])?$_REQUEST['manhom']:'';
	$masv=isset($_REQUEST['mssv'])?$_REQUEST['mssv']:'';
	$nhanxet=isset($_REQUEST['nhanxet'])?$_REQUEST['nhanxet']:'';
		$sqlnx = 'update dbo_dondangky set nhanxet=? where masv=? and manhom=?';
	$stmt2 = $db->prepare ($sqlnx );
	$stmt2->BindParam(1,$nhanxet);
	$stmt2->BindParam(2,$masv);
	$stmt2->BindParam(3,$manhom);
	$stmt2->execute();
		exit();
}
if(isset($_POST['btnsuat'])){
	$manhom=isset($_REQUEST['manhom'])?$_REQUEST['manhom']:'';
	$masv=isset($_REQUEST['mssv'])?$_REQUEST['mssv']:'';
	$thuong=isset($_REQUEST['thuong'])?$_REQUEST['thuong']:'';
		$sqlthuong = 'update dbo_dondangky set thuong=? where masv=? and manhom=?';
	$stmt3 = $db->prepare ($sqlthuong );
	$stmt3->BindParam(1,$thuong);
	$stmt3->BindParam(2,$masv);
	$stmt3->BindParam(3,$manhom);
	$stmt3->execute();
	exit();
}

$sqllop = 'select dbo_dondangky.MaSV,concat(holot," ",ten) as hoten,ThanhTich,NhanXet,Thuong From dbo_dondangky,dbo_sinhvien where manhom=? and dbo_dondangky.MASV=dbo_sinhvien.MASV';
$stmt1 = $db->prepare ($sqllop );
$stmt1->BindParam(1,$manhom);
$stmt1->execute();
$i=1;

?>
<table id="dssv" class="table table-bordered table-hover">
<thead>
			
			<tr class="info"><th>STT</th><th>MSSV</th><th>Họ tên</th><th>Thành Tích</th><th>Nhận xét</th><th>Thưởng</th></tr></thead>
			<tbody>
			
			</tbody>
			<?php 
	if($stmt1->execute()){
			
				while($r=$stmt1->fetch()){?>
				<tr>
					<td><?php echo $i++;?></td>
					<td><?php echo $r['MaSV'];?></td>
					<td><?php echo $r['hoten'];?></td>
					<td><input type="text" name="diem" id="diem"  value="<?php echo $r['ThanhTich'];?>" data-mssv="<?php echo $r['MaSV'];?>"/>						</td>				
					<td><input type="text" name="nhanxet" id="nhanxet"  value="<?php echo $r['NhanXet'];?>" data-mssv="<?php echo $r['MaSV'];?>"/>						</td>
					<td><input type="text" name="thuong" id="thuong"  value="<?php echo $r['Thuong'];?>" data-mssv="<?php echo $r['MaSV'];?>"/>						</td>
					
		<?php }} ?>	
			</tbody>
<tfoot>